package org.moonlight.jvm.classfile.constant.info.number;

import lombok.Getter;
import org.moonlight.jvm.classfile.ClassReader;
import org.moonlight.jvm.classfile.constant.ConstantInfo;

/**
 * CONSTANT_Float_info使用4字节存储IEEE754单精度浮点数常量，结构如下：
 *   CONSTANT_Float_info {
 *       u1  tag
 *       u4  bytes
 *   }
 *
 *   {@link ConstantInfo#CONSTANT_FLOAT}
 *
 * @author Moonlight
 * @createTime 2023/8/15 11:27
 **/
@Getter
public class ConstantFloatInfo implements ConstantInfo {

    private float val;

    @Override
    public void readInfo(ClassReader reader) {
        this.val = reader.readUint32ToFloat();
    }

    @Override
    public int tag() {
        return ConstantInfo.CONSTANT_FLOAT;
    }
}
